<template>
	<view class="page">
		<view class="infoContent">{{ infoContent }}</view>
		<view class="phoneButton" @click="callPhonList">一键拨打</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				infoId: 0,
				infoTitle: '',
				infoContent: '',
				infoPhoneList: [],
			}
		},
		async onLoad(option) {  //option为object类型，会序列化上个页面传递的参数
			await this.$onLaunched;
			this.infoId = option.infoId
			this.getNewsPaperInfoContent(this.infoId)
			uni.setNavigationBarTitle({
			    title: '信息详细'
			});
		},
		methods: {
			getNewsPaperInfoContent(infoid){
				this.$api.getNewsPaperInfoContent({id: infoid}).then( res =>{
					console.log(res)
					this.infoContent = res.data.Content
					this.infoTitle = res.data.title
					this.infoPhoneList = res.data.Phone
				})
			},
			callPhonList(){
				console.log(this.infoPhoneList)
				let tempList = []
				this.infoPhoneList.forEach(el =>{
					tempList.push(el.shouji)
				})
				uni.showActionSheet({
					itemList:tempList,
					success: (res) => {
						this.callPhone(tempList[res.tapIndex])
					},
				})
			},
			callPhone(number){
				uni.makePhoneCall({
				    phoneNumber: number //仅为示例
				});
			},
		}
	}
</script>

<style scoped>
@import url('newsPaperShow.css');
</style>
